<template>
	<view>
		<u-navbar :title="title1" :autoBack="false" leftIcon=" " placeholder></u-navbar>
		<view class="head">
			<view class="head__sousuo u-flex u-flex-y-center" @click="navto('/pages/contxt/searchpage')">
				<image src="/static/home/sousuo.png" class="head__sousuo__icon" mode=""></image>
				Search
			</view>
			<view class="u-flex u-flex-y-center" @click="navto('/pages/contxt/top10')">
				<image src="/static/home/rb.png" class="head__rb" mode=""></image>
				<view class="" style="flex: 1;">
					<swiper :vertical="true" :interval='true' interval='3000' style="height: 88rpx;" :autoplay="true">
						<swiper-item v-for="(item, index) in 10" :key="index" style="height: 88rpx;">
							<view class="u-flex u-flex-y-center u-flex-between" style="width: 100%;">
								<view class="head__text" :style="{textIndent:index<3?'36rpx':'0'}">
									<image v-if="index<3" :src="'/static/home/index'+(index+1)+'.png'" class="head__text__indexicon" mode=""></image>
									<text class="head__text__index" v-else>
										{{index+1}}
									</text>
									为什么把我骂公猪的删了 看不得我调教公猪?poasjdojskahdksajnbasd;jasldjakslhdkajnsh
								</view>
								<image src="/static/home/huo.png" class="head__icon" mode=""></image>
							</view>
						</swiper-item>

					</swiper>
				</view>
			</view>
		</view>
		
			<!-- #ifdef H5 -->
			<u-sticky bgColor="#f9f9f9" customNavHeight="44" offsetTop="0">
			<!-- #endif -->
			<!-- #ifndef H5 -->
			<u-sticky bgColor="#f9f9f9" customNavHeight="44" offsetTop="44">
			<!-- #endif -->
			<scroll-view scroll-x="true" style="width: 750rpx;">
				<view class="tabs">
					<view class="tabs__item" v-for="(item,index) in tablist" :key="index" @click="current=index"
						:class="current==index?'active':''">
						{{item.name}}
					</view>
				</view>
			</scroll-view>
		</u-sticky>
		<view class="list">
			<contentitem v-for="(item,index) in list" :item='item' :key="index" @dz='dz(item,index)'></contentitem>
		</view>
		<wanshan ref="wanshan"></wanshan>
		<tabbar :current="0"></tabbar>
	</view>
</template>

<script>
	import home from '@/api/_home.js'
	export default {
		data() {
			return {
				step: true,
				tablist: [{
						name: '最新',
						cate_id:''
					}],
				current: 0,
				list: [],
				page:1,
			};
		},
		onLoad() {
			this.getfl()
			this.getlist()
			uni.hideTabBar()
		},
		onPullDownRefresh() {
			this.list=[]
			this.page=1
			this.getlist()
		},
		methods: {
			dz(item, index) {
				// 判断是否完善
				if(!this.mobile){
					this.$refs.wanshan.open()
					return
				}
				item.isdz = !item.isdz
				this.$forceUpdate()
			},
			async getfl(){
				let res = await home.cate()
				if(res.data.code==1){
					this.tablist=[...this.tablist,...res.data.data]
				}
			},
			async getlist(){
				let res = await home.infoList({cate_id:this.tablist[this.current].cate_id,page:this.page})
				if(res.data.code==1){
					this.list=[...this.list,...res.data.data.data]
					this.list.map(t=>{
						t.cate=this.tablist.filter(t1=>t1.id==t.cate_id)[0].name
					})
					uni.stopPullDownRefresh()
				}
			},
			async gethot(){
				
			}
		}
	}
</script>

<style lang="scss">
	.head {
		padding: 40rpx 30rpx 6rpx;

		&__sousuo {
			height: 60rpx;
			background: #ffffff;
			border-radius: 31rpx 31rpx 31rpx 31rpx;
			border: 2rpx solid #7284C6;
			font-family: PingFang-SC, PingFang-SC;
			font-weight: bold;
			font-size: 31rpx;
			color: #6883EE;
			text-align: center;
			font-style: normal;
			text-transform: none;
			padding: 0 42rpx;
			margin-bottom: 33rpx;

			&__icon {
				width: 33rpx;
				height: 33rpx;
				margin-right: 10rpx;
			}
		}

		&__rb {
			width: 80rpx;
			height: 73rpx;
			margin-right: 19rpx;
		}

		&__text {
			width: 460rpx;
			font-family: PingFang-SC, PingFang-SC;
			font-weight: 500;
			font-size: 24rpx;
			color: #4C4B50;
			overflow: hidden;
			height: 88rpx;
			line-height: 44rpx;
			position: relative;
			&__indexicon{
				width: 30rpx;
				height: 38rpx;
				position: absolute;
				top: 6rpx;
				left: 0;
			}
			&__index{
				font-family: DINNextLTPro, DINNextLTPro;
				font-weight: 500;
				font-size: 24.43rpx;
				color: #90939A;
			}
		}

		&__icon {
			width: 122rpx;
			height: 88rpx;
		}
	}

	.tabs {
		height: 100rpx;
		display: flex;
		align-items: center;

		&__item {
			padding: 0 30rpx;
			font-family: PingFang-SC, PingFang-SC;
			font-weight: 500;
			font-size: 31rpx;
			color: #646464;
			text-align: center;
			font-style: normal;
			text-transform: none;
			flex-shrink: 0;
		}

		.active {
			color: #000000;
			font-size: 34rpx;
			font-weight: bold;
		}
	}

	.list {
		padding: 0 30rpx 20rpx 28rpx;

	}
</style>